class Formatter
  def format(text); puts "#{format_start}#{format_body(text)}#{format_end}"; end

  def format_body(text)
    "\ntext\n"
  end
end

class HtmlFormatter < Formatter
  def format_start
    %(<html>)
  end

  def format_end
    %(</html>)
  end
end

class TextFormatter < Formatter
  def format_start
    %(===start===)
  end

  def format_end
    %(===end===)
  end
end

class Report
  def initialize(formatter)
    @formatter = formatter
    @text = "test"
  end

  def output
    @formatter.new.format(@text)
  end
end

Report.new(HtmlFormatter).output
Report.new(TextFormatter).output